package com.hebeu.gfh.service.impl;

import com.hebeu.gfh.mapper.ClubMemberMapper;
import com.hebeu.gfh.pojo.po.ClubMember;
import com.hebeu.gfh.pojo.po.Clubs;
import com.hebeu.gfh.pojo.po.User;
import com.hebeu.gfh.pojo.vo.clubIdAndrole;
import com.hebeu.gfh.pojo.vo.userIdAndClubId;
import com.hebeu.gfh.service.clubMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 刘剑利
 * @Version: v1.0
 */
@Service("clubMemberService")
public class clubMemberServiceImpl implements clubMemberService {

    @Autowired
    ClubMemberMapper clubMemberMapper;
    @Override
    public List<User> findClubMember(clubIdAndrole clubIdAndrole) {
        List<User> userList ;
        if(clubIdAndrole.getRoleInClub()==0){
            userList = clubMemberMapper.findClubMember(clubIdAndrole.getClubId());
        }
        else if(clubIdAndrole.getRoleInClub()==5){
            userList = clubMemberMapper.findAllMember(clubIdAndrole.getClubId());
        }
        else
            userList = clubMemberMapper.findClubManager(clubIdAndrole.getClubId());
        return userList;
    }

    @Override
    public void joinClub(ClubMember clubMember) {
        clubMemberMapper.joinClub(clubMember);
    }

    @Override
    public void exitClub(int memberId) {
        clubMemberMapper.exitClub(memberId);
    }

    @Override
    public List<Clubs> findClubsListByuserId(int userId) {
        List<Clubs> clubsList = clubMemberMapper.findClubsListByuserId(userId);
        return clubsList;
    }

    @Override
    public Integer findmemberId(userIdAndClubId userIdAndClubId) {
        Integer memberId =clubMemberMapper.findmemberId(userIdAndClubId);
        return memberId;
    }

    @Override
    public void updateroleinclub(userIdAndClubId userIdAndClubId) {
        clubMemberMapper.updateroleinclub(userIdAndClubId);
    }

    @Override
    public List<User> getClubMember(int clubId) {
        List<User> userList = clubMemberMapper.findAllMember(clubId);
        return userList;
    }
}
